package com.zhaoxi.project.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.mes.domain.MesBomProcess;
import com.zhaoxi.project.mes.service.impl.MesBomProcessServiceImpl;
import com.zhaoxi.framework.web.controller.BaseController;
import com.zhaoxi.framework.web.domain.AjaxResult;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 物品工序清单Controller
 * 
 * @author zhaoxi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/mes/bomProcess")
public class MesBomProcessController extends BaseController
{
    @Autowired
    private MesBomProcessServiceImpl mesBomProcessService;

    /**
     * 查询物品工序清单列表
     */
    @PreAuthorize("@ss.hasPermi('mes:bomProcess:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesBomProcess mesBomProcess)
    {
        startPage();
        List<MesBomProcess> list = mesBomProcessService.selectMesBomProcessList(mesBomProcess);
        return getDataTable(list);
    }

    /**
     * 导出物品工序清单列表
     */
    @PreAuthorize("@ss.hasPermi('mes:bomProcess:export')")
    @Log(title = "物品工序清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesBomProcess mesBomProcess)
    {
        List<MesBomProcess> list = mesBomProcessService.selectMesBomProcessList(mesBomProcess);
        ExcelUtil<MesBomProcess> util = new ExcelUtil<MesBomProcess>(MesBomProcess.class);
        util.exportExcel(response, list, "物品工序清单数据");
    }

    /**
     * 获取物品工序清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:bomProcess:query')")
    @GetMapping(value = "/{goodsCode}")
    public AjaxResult getInfo(@PathVariable("goodsCode") String goodsCode)
    {
        return success(mesBomProcessService.selectMesBomProcessByGoodsCode(goodsCode));
    }

    /**
     * 新增物品工序清单
     */
    @PreAuthorize("@ss.hasPermi('mes:bomProcess:add')")
    @Log(title = "物品工序清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesBomProcess mesBomProcess)
    {
        return toAjax(mesBomProcessService.insertMesBomProcess(mesBomProcess));
    }

    /**
     * 修改物品工序清单
     */
    @PreAuthorize("@ss.hasPermi('mes:bomProcess:edit')")
    @Log(title = "物品工序清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesBomProcess mesBomProcess)
    {
        return toAjax(mesBomProcessService.updateMesBomProcess(mesBomProcess));
    }

    /**
     * 删除物品工序清单
     */
    @PreAuthorize("@ss.hasPermi('mes:bomProcess:remove')")
    @Log(title = "物品工序清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodsCodes}")
    public AjaxResult remove(@PathVariable String[] goodsCodes)
    {
        return toAjax(mesBomProcessService.deleteMesBomProcessByGoodsCodes(goodsCodes));
    }
}
